<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box1 {
        height: 200px;
        width: 200px;
        background-color: pink;
        border: 2px solid red;
        padding: 20px;
        box-sizing: border-box;
        /*padding和border不会撑大盒子了*/
    }

    .box2 {
        height: 200px;
        width: 200px;
        background-color: pink;
        border: 2px solid red;
        padding: 20px;

    }
</style>

<body>
    <div class="box1"></div>
    <div class="box2"></div>
    <script>
        // CSS3盒子模型
        //box-sizing 指定盒子模型
        // box-sizing:content-box 盒子大小为width+padding+border(以前默认的)
        //box-sizing:border-box    CSS3盒子模型最终的大小就是width的大小(padding和border不会撑大盒子了)

    </script>
</body>

</html>